<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="../../css/oksub.css">
	<script type="text/javascript" src="../../lib/loading/okLoading.js"></script>
	<style type="text/css">
	.layui-form-item .layui-input-inline{
	 width:auto;
	}
	.layui-form-pane .layui-form-label{
	 width: 150px;
	}
	.layui-form-pane .layui-input-block{
	margin-left: 150px;
	}
	</style>
</head>
<body>
<div class="ok-body">
	<!--form表单-->
	<form class="layui-form layui-form-pane ok-form">
		<div class="layui-form-item">
			<label class="layui-form-label">班別代碼</label>
			<div class="layui-input-block">
			 	<input class="layui-input"  name="CODE" autocomplete="off" id="CODE" onkeyup="this.value=this.value.toUpperCase()">
			  </div>	
		</div>	
		<div class="layui-form-item">
			<label class="layui-form-label">上班時數</label>
			<div class="layui-input-block">	
				<input class="layui-input"  name="HOURS" autocomplete="off" id="HOURS">
			</div>	
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">時間段</label>
			<div class="layui-input-block">	
				<input class="layui-input"  name="PERIOD" autocomplete="off" id="PERIOD">
			</div>	
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">說明</label>
			<div class="layui-input-block">	
				<input class="layui-input"  name="REMARK" autocomplete="off" id="REMARK">
			</div>	
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">夜班</label>
			<div class="layui-input-block">	
				 <select   id = "ISNIGHT" name = ISNIGHT> 
				      <option value='0'>否</option>
					  <option value='1'>是</option>
				 
				 </select>
		   </div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">類型</label>
			<div class="layui-input-block">	
				 <select   id = "TYPE" name = TYPE> 
				      <option value='1'>普通代碼</option>
					  <option value='2'>假期代碼</option>
				 
				 </select>
		   </div>
		</div>
	</form>
	
</div>
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script src="../../js/okform.js"></script>
<script>
     
    var ID = request("ID"); 
    var ManagerId = "";
    
    function AcceptClick() {
    	layui.use([ "okUtils"], function () {
    		let okUtils = layui.okUtils;
    		let $ = layui.jquery;
    		var saveCondition = {};
    		saveCondition['ID'] = ID;
    		saveCondition['CODE'] = $("#CODE").val();
    		saveCondition['ISNIGHT'] = $("#ISNIGHT").val();
    		saveCondition['HOURS'] = $("#HOURS").val();
    		saveCondition['TYPE'] = $("#TYPE").val();
    		saveCondition['PERIOD'] = $("#PERIOD").val();    		
    		saveCondition['REMARK'] = encodeURI( $("#REMARK").val().trim());
    		var searchcondition = JSON.stringify(saveCondition)
    		
    		okUtils.ajax("AttendancdCodeServlet?method=save", "POST", {searchcondition: searchcondition}, true).done(function (response) {
				   console.log(response);
				  
				}).fail(function (error) {
					console.log(error)
				});
    	})
    
    }
    
    
	layui.use(["element", "form","jquery", "laydate", "okLayer", "okUtils", "okMock"], function () {
		let form = layui.form;
		let laydate = layui.laydate;
		let okLayer = layui.okLayer;
		let okUtils = layui.okUtils;
		let table = layui.table;
		let okMock = layui.okMock;
		let $ = layui.jquery;
		
		okLoading.close();
		
	 if(ID){		 
			 okUtils.ajax("AttendancdCodeServlet?method=getOneData", "get", {ID: ID}, true).done(function (response) {
				   var data =response.data;									
				   $("#CODE").val(data.CODE);
				   $("#HOURS").val(data.HOURS);
				   $("#REMARK").val(data.REMARK);
				   $("#ATTEND_DATE").val(data.S_ATTEND_DATE);
				   $("#ISNIGHT").val(data.ISNIGHT);
				   $("#PERIOD").val(data.PERIOD);
				   $("#TYPE").val(data.TYPE);
				   form.render();
				}).fail(function (error) {
					console.log(error)
				});
		 }
			
	});
</script>
<!-- 行工具栏模板 -->
<script type="text/html" id="operationTpl">
	<a href="javascript:" title="编辑" lay-event="add"><i class="layui-icon">&#xe624;</i></a>
	<a href="javascript:" title="删除" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
</script>
</body>
</html>
